<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@ include file="../tld/tlds.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>浮动窗口</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">

		<link href="css/css.css" rel="stylesheet" type="text/css" />
		<script language="JavaScript" src="js/meihuaxue.js"></script>
		<script language="javaScript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/submit.js"></script>
		
</head>

<body>
<%
		    int typeid = 0;
		    int bigid = 0;
		    int smallid = 0;
		    String hql = "where isPic='888'";
		    LinkDAO linkDao = new LinkDAO();
		    Link link = new Link();
		    //当前页面
			int currPage = 1;
			//总的页数
			int totalPage = 1;
			//一个页面可显示的记录数
			int pageSize = 10;
			//总共有的记录数
			int totalCount = 1;
			List  li = new ArrayList();
			//li = linkDao.findAll();
			//得到总的记录数
			totalCount = linkDao.count(Link.class,hql);
			hql+=" order by linkOrder";
			//得到总的页数
			if(totalCount%pageSize==0){
				totalPage = totalCount/pageSize;
			}else{
				totalPage = totalCount/pageSize+1;
			}
			//判断是否是传过来页数
			if(request.getParameter("currPage") != null){
			   currPage = Integer.parseInt(request.getParameter("currPage"));
			   if(currPage<1){
			     currPage=1;
			    }
			   if(currPage >totalPage){
			     currPage = totalPage;
			   }
			} 
			//得到记录数
			
			  List li2 = linkDao.findPageByHql(hql,currPage,pageSize);
		 %>

<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" align="left" valign="middle" background="images/main_top.gif"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td width="400" height="23" align="left" valign="middle" class="ts_lmdh2">浮动窗口管理 </td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="20" align="left"><input type="button" value="添加浮动窗口" onclick="javascript:location='addAdver.jsp'"/></td>
        </tr>
      </table>
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
		<td height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">信息描述</td>
          <td width="20%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">网址URL</td>  
          <td width="15%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">图片预览</td>
          <td width="20%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">到期时间</td>
          <td width="5%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">顺序</td>
          <td width="20%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">操作</td>
        
        </tr>
       
	  <%
		  
		   for(int i = 0 ; i < li2.size(); i++){
			  link = (Link)li2.get(i);
			  
	  %>
	    <tr>
		<td height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		<%=link.getWebName()%>
		</td>
          <td  height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		 <%=link.getWebUrl()%>	  </td>
          <td width="15%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		<img src="../<%=link.getImg() %>" height="40" width="70"/>		  </td>
          <td  height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		 <%=link.getToDate()%>	  </td>
          <td  height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		 <%=link.getLinkOrder()%>	  </td>
  			<td  height="25" align="center" valign="middle" bgcolor="#FFFFFF">
			<a href="addAdver.jsp?id=<%=link.getLinkid() %>">修改</a>&nbsp;
			<a href="<%=request.getContextPath()%>/admin/managerLink.do?method=delById&linkid=<%=link.getLinkid() %>&isAdv=asd>">删除</a>			</td>
        </tr>
      <%
	  }
	  %>
	  
	
	  
	  </table>
	  
	  
	  
	  
	  
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">
		  共有［<%=totalCount %>］页 当前是第［<%=currPage %>/<%=totalPage %>］页 [
												<a href="adveroperate.jsp?currPage=1" class="page">首页</a>][
												<a href="adveroperate.jsp?currPage=<%=currPage-1 %>"
													class="page">上一页</a>][
												<a href="adveroperate.jsp?currPage=<%=currPage+1 %>"
													class="page">下一页</a>][
												<a href="adveroperate.jsp?currPage=<%=totalPage %>"
													class="page">尾页</a>]
		  到第
		  <select onchange="gopage(this)">
		  <%
				for(int i = 0;i<totalPage ; i++)
				{
					out.print("<option value='adveroperate.jsp?currPage="+(i+1)+"' "+(currPage==(i+1)?"checked":"")+">"+(i+1)+"</option>");
				}
			%>
		  </select>	
          页</td>
        </tr>
		<tr>
			<td>
				<font color="red">注意:浮动窗口的url地址要加http , 如:http://www.baidu.com</font>
			</td>
		</tr>
      </table></td>
  </tr>
</table>
</body>
</html>
<script language="javascript">
 function gopage(selected)
 {
 	window.open(selected.value,"_self");
 }
 </script>
<%@include file="inc/msg.jsp" %>